package cn.kennylee.codehub.mq.lip.integration.kafka.demo;

import cn.kennylee.codehub.mq.lip.integration.base.MessageVo;
import cn.kennylee.codehub.mq.lip.integration.kafka.listener.AbstractKafkaListener;
import cn.kennylee.codehub.mq.lip.integration.kafka.test.AbstractKafkaEmbeddedTest;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

/**
 * <p> Kafka消息监听器示例 </p>
 * <p>Created on 2025/6/13.</p>
 *
 * @author kennylee
 * @since 0.0.1
 */
@Component
@Slf4j
public class HelloKafkaListener extends AbstractKafkaListener {

    private static MessageVo messageVo;

    public HelloKafkaListener() {
        super(AbstractKafkaEmbeddedTest.TOPIC);
    }

    @Override
    public boolean processMessage(MessageVo messageVo) {
        log.info("Received message: {}", messageVo);
        HelloKafkaListener.messageVo = messageVo;
        return true;
    }

    public static MessageVo getLastMessage() {
        return messageVo;
    }
}
